export const setUserInfo = (info) => {
  uni.setStorageSync('userInfo', JSON.stringify(info))
}

export const getUserInfo = () => {
  const data = uni.getStorageSync('userInfo')
  if (data) {
    return JSON.parse(uni.getStorageSync('userInfo'))
  }
  return {}
}
export const removeUserInfo = (info) => {
  uni.removeStorageSync('userInfo')
}


export const messageSuccess = (title, cb) => {
  uni.showToast({
    title: title || '操作成功',
    icon: 'none',
    complete() {
      cb()
    }
  })
}

export const getYMD = (val) => {
  var year = val.getFullYear()
  var month = val.getMonth() + 1
  var date = val.getDate()
  if (date >= 1 && date <= 9) { // 日如果小于10就补个0
    date = '0' + date
  }
  if (month >= 1 && month <= 9) { // 月如果小于10就补个0
    month = '0' + month
  }
  return year + '-' + month + '-' + date
}